home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14241 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.2 KB  |  65 lines

  1. Path: user2.mnsinc.com!huang
  2. From: huang@mnsinc.com (Szu-Wen Huang)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: #including everything
  5. Date: 12 Apr 1996 19:37:53 GMT
  6. Organization: Monumental Network Systems
  7. Message-ID: <4kmbei$a2o@news1.mnsinc.com>
  8. References: <829297481snz@setch.demon.co.uk>
  9. NNTP-Posting-Host: user2.mnsinc.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Mark Setchell (Mark@setch.demon.co.uk) wrote:
  13.  
  14. : I suspect the disadvantages are:
  15. : 1) If it changes, all files have to be rebuilt - but that's ok it won't
  16. :    change often
  17.  
  18. If you have an include file that contains all standard library headers,
  19. the only time that file should change is when the standard library
  20. changes - not very ;).
  21.  
  22. : 2) It may bloat the size of the binaries by including unused variables,
  23. :    but that's not really a problem on Virtual Memory machines, and the
  24. :    increase in size isn't much anyway.
  25.  
  26. The include files contain declarations, not code or data.  A respectable
  27. compiler shouldn't add any code/data size penalty to your program because
  28. you included an unused header.
  29.  
  30. : 3) ???
  31.  
  32. Now for the bomb.  Your program can take forever to compile :) as your
  33. compiler chugs along uselessly through every single standard library
  34. header.  It can somewhat be alleviated if your compiler can do precompiled
  35. headers, but it's not going to be much.  My UX box here has about 2.7MB
  36. of stuff in /usr/include.  Think about compiling all of those for *each*
  37. source file you have.
  38.  
  39. : Weighed against this, the advantages are:
  40. : 1) porting and maintenance become easier with only one file to maintain
  41.  
  42. If maintenance really bothers you, try a hybrid approach:
  43.  
  44. #include "mystdio.h"  /* in your application code.  note the quotes */
  45.  
  46. and then your local stdio (mystdio.h) might do
  47.  
  48. #ifdef SGI
  49. #include <stdio.h>
  50. ... /* blah di blah
  51. #endif
  52.  
  53. This way, you avoid the useless recompilations of headers, and still have
  54. a relatively easy time maintaining it.  Obviously, if you use system-
  55. specific headers, your local stub header should be smart enough to handle
  56. the differences.
  57.  
  58. : 2) all system calls/functions are guaranteed to be prototyped
  59.  
  60. A respectable compiler should tell you this :)
  61.  
  62. : 3) ???
  63.  
  64. : Also, which system files should I #include?
  65.